package cn.hxzy.controller;


import cn.hxzy.domain.TaskManager;
import cn.hxzy.domain.vo.TaskManagerVo;
import cn.hxzy.response.R;
import cn.hxzy.service.TaskManagerService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDateTime;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author niuyi
 * @since 2024-06-22
 */
@RestController
@RequestMapping("/taskManager")
public class TaskManagerController {
    @Autowired
    private TaskManagerService taskManagerService;
    /**
     * 展示所有作业
     * @param
     * @return
     */
    @GetMapping("/TaskManagerList")
    public R taskManagerList(){
        List<TaskManager> list = taskManagerService.list();
        return R.success(list);
    }

    /**
     * 根据作业Id来查询学生作业
     * @param taskId
     * @return
     */
    @GetMapping("/selectTaskById")
    public R selectTaskById(@RequestParam Integer taskId){
        return null;
    }

    /**
     * 根据学生姓名来查询学生作业
     * @param userId
     * @return
     */
    @GetMapping("/selectTaskByStuName")
    public R selectTaskByStuName(@RequestParam("userId") Integer userId){
        List<TaskManager> taskManagerList = taskManagerService.getTaskManagerList(userId);
        return R.success(taskManagerList);
    }


    /**
     * 展示最后一次批复内容：作业名，作业描述，学生姓名，提交时间，提交次数
     * 讲师姓名，评价时间，评价次数
     * @param taskManager
     * @return
     */
    @GetMapping("evaluate")
    public R evaluate(@RequestBody TaskManager taskManager){
        return null;
    }

    /**
     * 修改批复
     * @param score
     * @param comment
     * @return
     */
    @RequestMapping("/updateEvaluate")
    public R updateEvaluate(@RequestParam Double score,@RequestParam String comment){
        return R.success("批复成功");
    }

    /**
     * 展示所有批复记录
     * @param taskId
     * @param studentId
     * @param teacherId
     * @return
     */
    @GetMapping("/AllevaluateByStuId")
    public R AllevaluateByStuId(@RequestParam Integer taskId,@RequestParam Integer studentId,@RequestParam Integer teacherId){
        return null;
    }


    /**
     * @param chapterId 作业id
     * @return
     */
    @GetMapping("/getHomeworkList")
    public R getHomeworkList(@RequestParam("chapterId") Integer chapterId){
        QueryWrapper queryWrapper = new QueryWrapper();
        queryWrapper.eq("chapter_id", chapterId);
        List<TaskManager> list = taskManagerService.list();
        return R.success(list);
    }

    /**
     * 根据编号得到作业管理详情
     * @param id
     * @return
     */
    @GetMapping("/getOneTask")
    public R getOneTask(@RequestParam Integer id){
        TaskManager byId = taskManagerService.getById(id);
        return R.success(byId);
    }
}

